import { Injectable } from '@nestjs/common';
import type { Repository } from 'typeorm';
import { Like } from 'typeorm';
import { InjectRepository } from '@nestjs/typeorm';
import { Girl } from './entities/girl.entity';
import { GirlDetail } from './entities/girlDetail.entity';
@Injectable()
export class GirlService {
  constructor(
    @InjectRepository(Girl) private readonly girl: Repository<Girl>,
  ) {}
  addGirl() {
    const data = new Girl();
    data.name = '冯舒楠';
    data.age = 18;
    data.skill = '哥哥遛';
    return this.girl.save(data);
  }
  delGirl(id: number) {
    return this.girl.delete(id);
  }
  updateGirl(id: number) {
    const data = new Girl();
    data.name = '冯舒楠';
    data.age = 20;
    return this.girl.update(id, data);
  }
  getGirls() {
    return this.girl.find();
  }
  getGirlByName(name: string) {
    return this.girl.find({
      where: { name: Like(`%${name}%`) },
    });
  }
}
